﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Meraz.Core.Model
{
    public class Post
    {
        public Post()
        {
            Permalink = "";
            Issues = new List<Issue>();
            Links = new List<Link>();
            Posters = new List<Poster>();
        }
        public int ID { get; set; }

        [DisplayName("Blog")]
        public string BlogName 
        {
            get { return this.BlogKeyType.ToString(); }
            set { this.BlogKeyType = (BlogKeyType)Enum.Parse(typeof(BlogKeyType), value); }
        }
        public BlogKeyType BlogKeyType { get; set; }

        [DisplayName("Permalink")]
        public string Permalink { get; set; }

        [DisplayName("Pubdate")]
        public DateTime Pubdate { get; set; }

        public string Published
        {
            get { return Pubdate.ToString(); }
            set { Pubdate = DateTime.Parse(value); }
        }


        [DisplayName("Title")]
        public string Title { get; set; }

        [DisplayName("Body")]
        public string Text { get { return Body.Name; } }

        public PostBody Body { get; set; }
        public virtual List<Poster> Posters { get; set; }
        public virtual List<Issue> Issues { get; set; }
        public virtual List<Link> Links { get; set; }

        public bool HasPosters { get { return Posters != null && Posters.Count > 0; } }
        public bool HasIssues { get { return Issues != null && Issues.Count > 0; } }
        public bool HasLinks { get { return Links != null && Links.Count > 0; } }
    }
}
